package com.qf.agro.common;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

import java.io.Serializable;

/**
 * ProjectName: smart-agriculture-parent
 * ClassName: ResultInfo
 * Author: chenyaosen
 * Date: 2023/6/29 16:16
 * Description:
 */
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ResultInfo implements Serializable {

    private Integer code;
    private String msg;
    private Object data;

    public static ResultInfo success(Object data) {
        ResultInfo resultInfo = new ResultInfo(Constant.OK,"成功",data);
        return resultInfo;
    }

    public static ResultInfo error(String message) {
        ResultInfo resultInfo = new ResultInfo(Constant.ERROR, message, null);
        return resultInfo;
    }

    public static ResultInfo noLogin(String message) {
        ResultInfo resultInfo = new ResultInfo(Constant.NOT_LOGIN_CODE, message, null);
        return resultInfo;
    }
}
